# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=popt
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.10.7
pkgrel=4
pkgdesc="C library for parsing command line parameters(mingw-w64)"
arch=('any')
url="http://www.rpm5.org/"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gettext")
options=('staticlibs' 'strip')
source=("http://rpm5.org/files/popt/popt-${pkgver}.tar.gz")
sha256sums=('04d945f6a9fbfef248c594e2fee5c1446987ad40c31ec8cf9b5fdbcbb3d6e35c')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  sed -e "s|MARK64=64|MARK64=|g" -i configure.ac
  libtoolize --force --copy
  autoreconf -fi
}

build() {
  export lt_cv_deplibs_check_method='pass_all'
  cp -r ${srcdir}/${_realname}-${pkgver} "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
}
